//package com.zlyx.easy.swagger.request;
//
//import java.lang.reflect.Method;
//import java.util.ArrayList;
//import java.util.List;
//
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.Signature;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.context.ApplicationContext;
//
//import com.zlyx.easy.core.annotations.SpringBean;
//import com.zlyx.easy.core.event.IHandlerOnRefreshed;
//import com.zlyx.easy.core.tool.Ops;
//import com.zlyx.easy.core.utils.LogUtils;
//import com.zlyx.easy.core.utils.MethodUtils;
//import com.zlyx.easy.core.utils.ProxyUtils;
//import com.zlyx.easy.core.utils.RequestUtils;
//import com.zlyx.easy.log.annotations.EasyLog;
//import com.zlyx.easy.log.aspect.abstracts.AbstractLogAspect;
//import com.zlyx.easy.swagger.annotations.SpringController;
//import com.zlyx.easy.swagger.annotations.SpringMapping;
//
//@Aspect
//@SpringBean(todo = { "请求切面" })
//public class RequestAspect extends AbstractLogAspect implements IHandlerOnRefreshed {
//
//	private List<String> urls = new ArrayList<>();
//
//	@Pointcut("@annotation(com.zlyx.easy.swagger.annotations.SpringMapping)||"
//			+ "@annotation(org.springframework.web.bind.annotation.RequestMapping) ||"
//			+ "@annotation(org.springframework.web.bind.annotation.PostMapping) ||"
//			+ "@annotation(org.springframework.web.bind.annotation.GetMapping)")
//	public void webAspect() {
//	}
//
//	@Around("webAspect()")
//	public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
//		try {
//			String url = RequestUtils.getRequest().getRequestURI();
//			if (Ops.isEmpty(url) || urls.contains(url)) {
//				return pjp.proceed();
//			}
//			Object res = null;
//			Signature signature = pjp.getSignature();
//			MethodSignature methodSignature = (MethodSignature) signature;
//			Method targetMethod = methodSignature.getMethod();
//			Class<?> realClass = ProxyUtils.getTarget(pjp.getTarget()).getClass();
//			SpringController springController = realClass.getAnnotation(SpringController.class);
//			Method realMethod = MethodUtils.getRealMethod(realClass, targetMethod);
//			SpringMapping springMapping = realMethod.getAnnotation(SpringMapping.class);
//			if (springController == null || springMapping == null) {
//				return doProcess(pjp, realClass, realMethod);
//			}
//			if (properties.getLevel() <= 1 && realMethod.getAnnotation(EasyLog.class) == null) {
//				res = doPrint(pjp, realClass, realMethod, url, springMapping.todo());
//			} else {
//				res = doProcess(pjp, realClass, realMethod);
//			}
//			return res;
//		} catch (Exception e) {
//			LogUtils.err(pjp.getTarget().getClass(), e);
//			return null;
//		}
//	}
//
//	@Override
//	public void doOnRefreshed(ApplicationContext context) {
//		if (aspectProcess != null) {
//			urls = aspectProcess.addUrl(urls);
//		}
//		urls.add("/error");
//		urls.add("/swagger-resources");
//	}
//}
